<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>项目管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
			$("#btnImport").click(function(){
				$.jBox($("#importBox").html(), {title:"导入数据", buttons:{"关闭":true}, 
					bottomText:"导入文件不能超过5M，仅允许导入“xls”或“xlsx”格式文件！"});
			});
			$("#btnImportPic").click(function(){
				$.jBox($("#importPicBox").html(), {title:"导入数据", buttons:{"关闭":true}, 
					bottomText:"仅允许导入“zip”格式文件！"});
			});
			
			$("#checkAll").click(function() {        
				$('input[name="subBox"]').attr("checked",this.checked);       
			});
			var $subBox = $("input[name='subBox']");      
			$subBox.click(function(){        
				$("#checkAll").attr("checked",$subBox.length == $("input[name='subBox']:checked").length ? true : false);      
			});
		});
		 function page(n,s){
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").submit();
        	return false;
        } 
		 
		 function batchDeletes() {
				//判断至少写了一项
				var checkedNum = $("input[name='subBox']:checked").length;
				if (checkedNum == 0) {
					alert("请至少选择一项!");
					return false;
				}
				if (confirm("确定删除所选项目?")) {
					var checkedList = new Array();
					$("input[name='subBox']:checked").each(function() {
						checkedList.push($(this).val());
					});
					$.ajax({
						type : "POST",
						url : ctx+"/project/sfProject/batchDeletes",
						data : {
							"delitems" : checkedList.toString()
						},
						datatype : "html",
						success : function(data) {
							alert('删除成功!');
							setTimeout("location.reload()", 1000);//页面刷新
						},
						error : function(data) {
							alert('删除失败!');
						}
					});
				}
			}
		 
		 
	</script>
</head>
<body>
	<div id="importBox" class="hide">
		<form id="importForm" action="${ctx}/project/sfProject/import" method="post" enctype="multipart/form-data" 
		class="form-search" style="padding-left:20px;text-align:center;" onsubmit="loading('正在导入，请稍等...');"><br/>
			<input id="uploadFile" name="file" type="file" style="width:330px"/><br/><br/>　　
			<input id="btnImportSubmit" class="btn btn-primary" type="submit" value="   导    入   "/>
<%-- 			<a href="${ctx}/project/sfProject/import/template">下载模板</a> --%>
		</form>
	</div>
	<div id="importPicBox" class="hide">
		<form id="importPicForm" action="${ctx}/project/sfProject/importPic" method="post" enctype="multipart/form-data" 
		class="form-search" style="padding-left:20px;text-align:center;" onsubmit="loading('正在导入，请稍等...');"><br/>
			<input id="uploadPicFile" name="mfile" type="file" style="width:330px"/><br/><br/>　　
			<input id="btnImportPicSubmit" class="btn btn-primary" type="submit" value="   导    入   "/>
<%-- 			<a href="${ctx}/project/sfProject/import/template">下载模板</a> --%>
		</form>
	</div>
	<ul class="nav nav-tabs">
		<li class="active"><a href="${ctx}/project/sfProject/">项目列表</a></li>
		<shiro:hasPermission name="project:sfProject:edit"><li><a href="${ctx}/project/sfProject/form">项目添加</a></li></shiro:hasPermission>
	</ul>
	<form:form id="searchForm" modelAttribute="sfProject" action="${ctx}/project/sfProject/" method="post" class="breadcrumb form-search">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
		<ul class="ul-form">
			<li><label>编码：</label>
				<form:input path="code" htmlEscape="false" maxlength="64" class="input-medium"/>
			</li>
			<li><label>名称：</label>
				<form:input path="name" htmlEscape="false" maxlength="64" class="input-medium"/>
			</li>
			<li><label>英文名称：</label>
				<form:input path="enName" htmlEscape="false" maxlength="64" class="input-medium"/>
			</li>
			<li class="btns">
				<input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/>
				<input id="btnImport" class="btn btn-primary" type="button" value="导入"/>
				<input id="btnImportPic" class="btn btn-primary" type="button" value="导入图片"/>
				<input type="button" onclick="batchDeletes()" value="批量删除"  class="btn btn-primary">
			</li>
			<li class="clearfix"></li>
		</ul>
	</form:form>
	<sys:message content="${message}"/>
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
		<thead>
			<tr>
			<th><input id="checkAll" type="checkbox"   /></th>
				<th>编码</th>
				<th>名称</th>
				<th>英文名称</th>
				<th>类型</th>
				<th>英文类型</th>
				<th>客户名称</th>
				<th>英文客户名称</th>
				<th>所属区域</th>
				<th>英文所属区域</th>
				<th>城市</th>
				<th>英文城市</th>
				<th>图片存放</th>
				<shiro:hasPermission name="project:sfProject:edit"><th>操作</th></shiro:hasPermission>
			</tr>
		</thead>
		<tbody>
		<c:forEach items="${page.list}" var="sfProject">
			<tr>
			    <td><input  name="subBox" type="checkbox" value="${sfProject.id}" /></td>
				<td><a href="${ctx}/project/sfProject/form?id=${sfProject.id}">${sfProject.code}</a></td>
				<td>${sfProject.name}</td>
				<td>${sfProject.enName}</td>
				<td>${sfProject.type }</td>
				<td>${sfProject.enType }</td>
				<td>${sfProject.customName}</td>
				<td>${sfProject.enCustomName}</td>
				<td>${sfProject.area}</td>
				<td>${sfProject.enArea}</td>
				<td>${sfProject.city}</td> 
				<td>${sfProject.enCity}</td>
				<td>${sfProject.existImage}</td>
				<shiro:hasPermission name="project:sfProject:edit"><td>
    				<a href="${ctx}/project/sfProject/form?id=${sfProject.id}">修改</a>
					<a href="${ctx}/project/sfProject/delete?id=${sfProject.id}" onclick="return confirmx('确认要删除该项目吗？', this.href)">删除</a>
					<a href="${ctx}/product/sfProduct/projectproductlist?pid=${sfProject.id}">下属产品</a>
				</td></shiro:hasPermission>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	<div class="pagination">${page}</div>
</body>
</html>